# Create your views here.
from django.shortcuts import get_object_or_404, render_to_response
from django.http import HttpResponseRedirect, HttpResponse, Http404
from django.core.urlresolvers import reverse
from django.template import RequestContext
from users.models import UserProfile
from django.contrib.auth.decorators import login_required
from django.contrib.auth import authenticate, login, logout
from django.contrib.auth.models import User
from django.core.exceptions import ObjectDoesNotExist

#@login_required()
def profile (request) : 
	user = User.objects.get(pk = user_id)
	user.userprofile = get_or_create_profile(user)
    	return render_to_response('accounts/user.html', {})

def get_or_create_profile( user ) : 
	try:
		profile = user.get_profile()
	except:
		ObjectDoesNotExist
	profile = UserProfile(company = "LOLZ INC.", email='lol@lol.com', user=user)
	profile.save()
	return profile
